	package cs342.uwosh.group1.mycontacts.Threads;

	import java.util.ArrayList;
	import java.util.List;

import com.mycontacts.R;
import com.mycontacts.R.id;
import com.mycontacts.R.layout;

import cs342.uwosh.group1.mycontacts.Contact;
import cs342.uwosh.group1.mycontacts.DeleteContactsChooser;
import cs342.uwosh.group1.mycontacts.MainActivity;
import cs342.uwosh.group1.mycontacts.SqlConnect;

	import android.os.AsyncTask;
import android.widget.ArrayAdapter;

	public class GetAllContactsChooserTask extends AsyncTask<Object, Object, List<Contact>>{

		
		@Override
		protected List<Contact> doInBackground(Object... arg0) {

			SqlConnect db = MainActivity.db;
			
			return db.getAll();
		}
		
		/**
		 * 
		 */
		protected void onPostExecute(List<Contact> result)
		{
			ArrayList<Contact> contacts = (ArrayList<Contact>) result;
			
			DeleteContactsChooser.deletecontactListAdapter = new ArrayAdapter<Contact>(DeleteContactsChooser.mainContext, R.layout.populate_delete_chooser_list_item, R.id.deleteContactItem, contacts);
			DeleteContactsChooser.sizeOfAdapter = DeleteContactsChooser.deletecontactListAdapter.getCount();
			DeleteContactsChooser.listOfDeleteContacts.setAdapter(DeleteContactsChooser.deletecontactListAdapter);
		}
	}